<?php
namespace App\Controllers\Activity;

use App\Models\Activity\Activity;
use App\Libs\Views\Json;
/**
    //获取活动列表
 */
class GetActivityList extends \App\Libs\Base\BaseAction
{
    public function execute()
    {
        $page = $this->request->getQuery('page','int',1);
        $size = $this->request->getQuery('size','int',10);
        $offset = ($page-1)*$size;
        $allActivity = Activity::findAll([
            '1=1',
            'columns' => 'id,ligo,title,area,trange,sttime,push',
            'order' => 'push desc',
            'offset' => $offset,
            'limit' => $size
        ])->toArray();
        $activityNum = Activity::count('1=1');
        if(empty($allActivity)){
            return Json::view(0,'没有更多数据了',['ac_data'=> [],'sum'=>$activityNum]);
        }else{
            return Json::view(0,'ok',['ac_data'=> $allActivity,'sum'=>$activityNum]);
        }
    }
}
